#!/bin/env python
#coding=utf-8
'''
author: monkey
输入：
UO 乱序数量
IR 断流数量

4444 tvload 异常
5555 ss挂了
'''
import __future__
import re,os,sys


input_argv = str(sys.argv[1])

tvload_err_code = 4444
ss_down_code = 5555


ss_used_path = '/opt/fonsview/NE/ss/data/proc/rem/used'
# ss_used_path = '/home/monkey/sync/work_note/ss1_online.txt'


def main():
    ret_code = 0
    if not os.path.isfile(ss_used_path): return ss_down_code
        
    with open(ss_used_path,'r') as file:
        data = file.readlines()

    if not data: return tvload_err_code

    for x in data:
        ss_tags = re.findall(input_argv + ':\d',x)
        if ss_tags:                
            if ss_tags[0] != (input_argv + ':0'):
              ret_code = ret_code + 1
            else:
                ret_code

    return ret_code

if __name__ == '__main__':
    code = main()
    print(code)